﻿using System;

namespace BoldBrick.OneIntranet.HR.FieldTypes
{
	/// <summary>
	/// Value for <see cref="ContentTypeLookup"/> field
	/// </summary>
	[Serializable]
	public class ContentTypeLookupValue
	{
		/// <summary>
		/// Content type ID
		/// </summary>
		public string ContentTypeId { get; private set; }

		/// <summary>
		/// Content type name
		/// </summary>
		public string ContentTypeName { get; private set; }

		public ContentTypeLookupValue(string contentTypeId, string contentTypeName)
		{
			this.ContentTypeId = contentTypeId;
			this.ContentTypeName = contentTypeName;
		}

		public ContentTypeLookupValue(string value)
		{
			string[] values = value.Split(';');
			if (values.Length != 2)
				throw new ArgumentException("Value has to in <something>;#<something> format.", value);

			this.ContentTypeId = values[0];
			this.ContentTypeName = values[1];
		}

		public override string ToString()
		{
			return string.Format("{0};{1}", this.ContentTypeId, this.ContentTypeName);
		}
	}
}
